unit DadosUltimaZ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;

type
  TFormDadosUltimaz = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    GroupBox3: TGroupBox;
    Label3: TLabel;
    GroupBox4: TGroupBox;
    Label4: TLabel;
    GroupBox5: TGroupBox;
    Label5: TLabel;
    GroupBox6: TGroupBox;
    Label6: TLabel;
    GroupBox7: TGroupBox;
    Label7: TLabel;
    GroupBox8: TGroupBox;
    Label8: TLabel;
    GroupBox9: TGroupBox;
    Label9: TLabel;
    GroupBox10: TGroupBox;
    Label10: TLabel;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    GroupBox11: TGroupBox;
    Label11: TLabel;
    StringGrid3: TStringGrid;
    GroupBox12: TGroupBox;
    Label12: TLabel;
    GroupBox13: TGroupBox;
    Label13: TLabel;
    GroupBox14: TGroupBox;
    Label14: TLabel;
    GroupBox15: TGroupBox;
    Label15: TLabel;
    GroupBox16: TGroupBox;
    Label16: TLabel;
    GroupBox17: TGroupBox;
    Label17: TLabel;
    GroupBox18: TGroupBox;
    Label18: TLabel;
    GroupBox19: TGroupBox;
    Label19: TLabel;
    GroupBox21: TGroupBox;
    Label21: TLabel;
    GroupBox23: TGroupBox;
    Label23: TLabel;
    StringGrid4: TStringGrid;
    GroupBox25: TGroupBox;
    Label25: TLabel;
    GroupBox26: TGroupBox;
    Label26: TLabel;
    GroupBox20: TGroupBox;
    Label20: TLabel;
    GroupBox22: TGroupBox;
    Label22: TLabel;
    GroupBox24: TGroupBox;
    Label24: TLabel;
    GroupBox27: TGroupBox;
    Label27: TLabel;
    GroupBox28: TGroupBox;
    Label28: TLabel;
    GroupBox29: TGroupBox;
    Label29: TLabel;
    GroupBox30: TGroupBox;
    Label30: TLabel;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  type
        RegUltimaZ = record
        ModoRZ: Array[0..2] of char;
        CRO: Array[0..4] of char;
        CRZ: Array[0..4] of char;
        COO: Array[0..6] of char;
        GNF: Array[0..6] of char;
        CCF: Array[0..6] of char;
        GRG: Array[0..6] of char;
        CFD: Array[0..6] of char;
        NFC: Array[0..4] of char;
        CFC: Array[0..4] of char;
        CON: Array[0..29] of Array[0..3] of char;
        Separador: char;
        CER: Array[0..29] of Array[0..3] of char;
        Separador2: char;
        CDC: Array[0..4] of char;
        CDN: Array[0..4] of char;
        VAZIO: Array[0..4] of char;
        GT: Array[0..18] of char;
        ParciaisTributados: Array[0..15] of Array[0..13] of char;
        Separador3: char;
        I_ICMS: Array[0..14] of char ;
        N_ICMS: Array[0..14] of char ;
        F_ICMS: Array[0..14] of char ;
        I_ISS: Array[0..14] of char ;
        N_ISS: Array[0..14] of char ;
        F_ISS: Array[0..14] of char ;
        D_ICMS: Array[0..14] of char ; // desconto
        D_ISS: Array[0..14] of char ;
        A_ICMS: Array[0..14] of char ; // acrescimo
        A_ISS: Array[0..14] of char ;
        C_ICMS: Array[0..14] of char ; // Cancelamento
        C_ISS: Array[0..14] of char ;
        ParciaisNaoTributados: Array[0..27] of Array[0..13] of char;
        Separador4: char;
        SANGRIA: Array[0..14] of char ;
        SUPRIMENTO: Array[0..14] of char ;
        C_NFISC: Array[0..14] of char ; // Cancelamento nao fiscal
        D_NFISC: Array[0..14] of char ; // Desconto nao fiscal
        A_NFISC: Array[0..14] of char ; // Acréscimo nao fiscal
        Aliquotas: Array[0..15] of Array[0..3] of char;
        Separador5: char;
        DataMovimento: Array[0..6] of char;
    end;

var
  FormDadosUltimaz: TFormDadosUltimaz;
  dadosZ:RegUltimaZ;

implementation

uses principal, funcoesapoio, declaracoes;

{$R *.dfm}

procedure TFormDadosUltimaz.FormShow(Sender: TObject);
var i:integer;
begin
         // Dados Última Redução MFD ------------------------------------------------------------------
        FormPrincipal.Statusbar1.Panels[0].Text:='Dados Ultima Redução MFD:'; WaitProcess;
        Resposta:=ECF_DadosUltimaReducaoMFD(Conteudo);
        CopyMemory(@dadosZ,@conteudo,1278);
        FormPrincipal.Memo1.Lines.Add('Dados Ultima Redução MFD:'+inttostr(Resposta));
        VerificaRetornoFuncao(Resposta);

        if dadosz.ModoRZ[1]='0' then Label1.Caption:='RZ Modo Manual'
        else if dadosz.ModoRZ[1]='1' then Label1.Caption:='RZ Modo Automático';
        Label2.Caption:=dadosz.CRO;
        Label3.Caption:=dadosz.CRZ;
        Label4.Caption:=dadosz.COO;
        Label5.Caption:=dadosz.GNF;
        Label6.Caption:=dadosz.CCF;
        Label7.Caption:=dadosz.GRG;
        Label8.Caption:=dadosz.CFD;
        Label9.Caption:=dadosz.NFC;
        Label10.Caption:=dadosz.CFC;
        Label11.Caption:=dadosz.CDC;
        StringGrid1.Cells[0,0]:='CON';
        for i:=1 to 30 do begin
                StringGrid1.Cells[0,i]:=dadosZ.CON[i-1];
        end;
        StringGrid2.Cells[0,0]:='CER';
        for i:=1 to 30 do begin
                StringGrid2.Cells[0,i]:=dadosZ.CER[i-1];
        end;
        StringGrid3.Cells[0,0]:='Parciais Tributados';
        for i:=1 to 16 do begin
                StringGrid3.Cells[0,i]:=Format('%14.2f', [StrToFloat(copy(dadosZ.ParciaisTributados[i-1],1,14))/100]);
        end;
        Label12.Caption:=Format('%18.2f',[StrToFloat(copy(dadosz.GT,1,18))/100]);
        Label13.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.I_ICMS,1,14))/100]);
        Label14.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.N_ICMS,1,14))/100]);
        Label15.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.F_ICMS,1,14))/100]);
        Label16.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.I_ISS,1,14))/100]);
        Label17.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.N_ISS,1,14))/100]);
        Label18.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.F_ISS,1,14))/100]);
        Label19.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.D_ICMS,1,14))/100]);
        Label20.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.D_ISS,1,14))/100]);
        Label21.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.A_ICMS,1,14))/100]);
        Label22.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.A_ISS,1,14))/100]);
        Label23.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.C_ICMS,1,14))/100]);
        Label24.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.C_ISS,1,14))/100]);

        StringGrid4.Cells[0,0]:='Alíquotas';
        for i:=1 to 16 do begin
                StringGrid4.Cells[0,i]:=Format('%4.2f', [StrToFloat(copy(dadosZ.Aliquotas[i-1],1,4))/100]);
        end;
        Label25.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.Sangria,1,14))/100]);
        Label26.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.Suprimento,1,14))/100]);
        Label27.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.D_NFISC,1,14))/100]);
        Label28.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.A_NFISC,1,14))/100]);
        Label29.Caption:=Format('%14.2f',[StrToFloat(copy(dadosz.C_NFISC,1,14))/100]);
        Label30.Caption:=Format('%s/%s/%s',[Copy(dadosZ.DataMovimento,1,2),Copy(dadosZ.DataMovimento,3,2),Copy(dadosZ.DataMovimento,3,2)]);
end;

end.
